from django.contrib.admin import ModelAdmin, StackedInline

from app.models import Category, Product


class CategoryInline(StackedInline):
    model = Category
    extra = 0


class ProductInline(StackedInline):
    model = Product
    extra = 0


class CategoryAdmin(ModelAdmin):
    list_display = ('id', 'name', 'image', 'parent_category')
    inlines = (CategoryInline, ProductInline)
    list_filter = ('parent_category',)
    search_fields = ('name',)
